// const Ajv = require('ajv');
// const ajv = new Ajv();
// const vaildata = ajv.compile(xxxx);
const question = {
    "type": "object",
    "properties": {
        "title": {
            "type": "string",
            "description": "题目"
        },
        "type": {
            "type": "integer",
            "description": "题目类型",
            "enum": [
                1,
                2,
                3,
                4,
                5
            ]
        },
        "analysis": {
            "type": "string",
            "description": "解析"
        },
        "difficulty": {
            "type": "number",
            "description": "难度"
        },
        "qt_body":{
            "type":"object",
            "description":"题目主体"
        }
    },
    "required": [
        "title",
        "type",
        "analysis",
        "qt_body",
        "difficulty"
    ]
}

const ChoiceQuestion = {
    "type": "object",
    "properties": {
        "title": {
            "type": "string",
            "description": "题目"
        },
        "type": {
            "type": "integer",
            "description": "题目类型",
            "minimum": 2,
            "maximum": 2
        },
        "analysis": {
            "type": "string",
            "description": "解析"
        },
        "difficulty": {
            "type": "number",
            "description": "难度"
        },
        "qt_body": {
            "type": "object",
            "properties": {
                "selections": {
                    "type": "array",
                    "items": {
                        "type": "string",
                        "description": "选项"
                    },
                    "description": "选项数组"
                },
                "answers": {
                    "type": "array",
                    "items": {
                        "type":"integer",
                        "description": "答案项"
                    },
                    "description": "答案数组"
                },
                "scoreDefault": {
                    "type": [
                        "array",
                        "null"
                    ],
                    "items": {
                        "type": "number",
                        "description": "默认分数"
                    },
                    "description": "默认分数数组"
                }
            },
            "required": [
                "selections",
                "answers",
                "scoreDefault"
            ],
            "description": "选择题主体",
            "additionalProperties": false
        }
    },
    "required": [
        "title",
        "type",
        "analysis",
        "qt_body",
        "difficulty"
    ],
    "additionalProperties": false
}
const blankQuestion = {
    "type": "object",
    "properties": {
        "title": {
            "type": "string",
            "description": "题目"
        },
        "type": {
            "type": "integer",
            "description": "题目类型",
            "minimum": 3,
            "maximum": 3
        },
        "analysis": {
            "type": "string",
            "description": "解析"
        },
        "difficulty": {
            "type": "number",
            "description": "难度"
        },
        "qt_body": {
            "type": "object",
            "properties": {
                "answers": {
                    "type": "array",
                    "items": {
                        "type": "string",
                        "description": "填空题答案选项"
                    },
                    "description": "填空题答案数组"
                },
                "scoreDefault": {
                    "type": [
                        "array",
                        "null"
                    ],
                    "items": {
                        "type": "number",
                        "description": "默认分数"
                    },
                    "description": "默认分数数组"
                }
            },
            "description": "填空题主体",
            "required": [
                "answers",
                "scoreDefault"
            ],
            "additionalProperties": false
        }
    },
    "required": [
        "title",
        "type",
        "analysis",
        "qt_body",
        "difficulty"
    ],
    "additionalProperties": false
}
const judgingQuestion = {
    "type": "object",
    "properties": {
        "title": {
            "type": "string",
            "description": "题目"
        },
        "type": {
            "type": "integer",
            "description": "题目类型",
            "minimum": 4,
            "maximum": 4
        },
        "analysis": {
            "type": "string",
            "description": "解析"
        },
        "difficulty": {
            "type": "number",
            "description": "难度"
        },
        "qt_body": {
            "type": "object",
            "properties": {
                "answers": {
                    "type": "boolean",
                    "description": "判断题答案"
                },
                "scoreDefault": {
                    "type": "number",
                    "description": "默认分数"
                }
            },
            "description": "判断题主体",
            "required": [
                "answers",
                "scoreDefault"
            ],
            "additionalProperties": false
        }
    },
    "required": [
        "title",
        "type",
        "analysis",
        "qt_body",
        "difficulty"
    ],
    "additionalProperties": false
}
const shortAnswerQuestion = {
    "type": "object",
    "properties": {
        "title": {
            "type": "string",
            "description": "题目"
        },
        "type": {
            "type": "integer",
            "description": "题目类型",
            "minimum": 5,
            "maximum": 5
        },
        "analysis": {
            "type": "string",
            "description": "解析"
        },
        "difficulty": {
            "type": "number",
            "description": "难度"
        },
        "qt_body": {
            "type": "object",
            "properties": {
                "answers": {
                    "type": "string",
                    "description": "简答题答案"
                },
                "scoreDefault": {
                    "type": "number",
                    "description": "默认分数"
                }
            },
            "description": "简答题主体",
            "required": [
                "answers",
                "scoreDefault"
            ],
            "additionalProperties": false
        }
    },
    "required": [
        "title",
        "type",
        "analysis",
        "qt_body",
        "difficulty"
    ],
    "additionalProperties": false
}

const ChoiceQuestionBody = {
    "type": "object",
    "properties": {
        "selections": {
            "type": "array",
            "items": {
                "type": "string",
                "description": "选项"
            },
            "description": "选项数组"
        },
        "answers": {
            "type": "array",
            "items": {
                "type": "string",
                "description": "答案项"
            },
            "description": "答案数组"
        },
        "scoreDefault": {
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "number",
                "description": "默认分数"
            },
            "description": "默认分数数组"
        }
    },
    "required": [
        "selections",
        "answers",
        "scoreDefault"
    ],
    "description": "选择题主体"
}
const blankQuestionBody = {
    "type": "object",
    "properties": {
        "answers": {
            "type": "array",
            "items": {
                "type": "string",
                "description": "填空题答案选项"
            },
            "description": "填空题答案数组"
        },
        "scoreDefault": {
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "number",
                "description": "默认分数"
            },
            "description": "默认分数数组"
        }
    },
    "description": "填空题主体",
    "required": [
        "answers",
        "scoreDefault"
    ]
}
const judgingQuestionBody = {
    "type": "object",
    "properties": {
        "answers": {
            "type": "boolean",
            "description": "判断题答案"
        },
        "scoreDefault": {
            "type": "number",
            "description": "默认分数"
        }
    },
    "description": "判断题主体",
    "required": [
        "answers",
        "scoreDefault"
    ]
}
const shortAnswerQuestionBody = {
    "type": "object",
    "properties": {
        "answers": {
            "type": "string",
            "description": "简答题答案"
        },
        "scoreDefault": {
            "type": "number",
            "description": "默认分数"
        }
    },
    "description": "简答题主体",
    "required": [
        "answers",
        "scoreDefault"
    ]
}

let a = {
    "type": "object",
    "properties": {
        "questionArray": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "title": {
                        "type": "string",
                        "description": "题目"
                    },
                    "type": {
                        "type": "integer",
                        "description": "题目类型",
                        "enum": [
                            1,
                            2,
                            3,
                            4,
                            5
                        ]
                    },
                    "analysis": {
                        "type": "string",
                        "description": "解析"
                    },
                    "difficulty": {
                        "type": "integer",
                        "description": "难度"
                    },
                    "qt_body": {
                        "oneOf": [
                            {
                                "type": "object",
                                "properties": {
                                    "selections": {
                                        "type": "array",
                                        "items": {
                                            "type": "string",
                                            "description": "选项"
                                        },
                                        "description": "选项数组"
                                    },
                                    "answers": {
                                        "type": "array",
                                        "items": {
                                            "type": "string",
                                            "description": "答案项"
                                        },
                                        "description": "答案数组"
                                    },
                                    "scoreDefault": {
                                        "type": [
                                            "array",
                                            "null"
                                        ],
                                        "items": {
                                            "type": "string",
                                            "description": "默认分数"
                                        },
                                        "description": "默认分数数组"
                                    }
                                },
                                "required": [
                                    "selections",
                                    "answers",
                                    "scoreDefault"
                                ],
                                "description": "选择题主体"
                            },
                            {
                                "type": "object",
                                "properties": {
                                    "answers": {
                                        "type": "array",
                                        "items": {
                                            "type": "string",
                                            "description": "填空题答案选项"
                                        },
                                        "description": "填空题答案数组"
                                    },
                                    "scoreDefault": {
                                        "type": [
                                            "array",
                                            "null"
                                        ],
                                        "items": {
                                            "type": "integer",
                                            "description": "默认分数"
                                        },
                                        "description": "默认分数数组"
                                    }
                                },
                                "description": "填空题主体",
                                "required": [
                                    "answers",
                                    "scoreDefault"
                                ]
                            },
                            {
                                "type": "object",
                                "properties": {
                                    "answers": {
                                        "type": "boolean",
                                        "description": "判断题答案"
                                    },
                                    "scoreDefault": {
                                        "type": "integer",
                                        "description": "默认分数"
                                    }
                                },
                                "description": "判断题主体",
                                "required": [
                                    "answers",
                                    "scoreDefault"
                                ]
                            },
                            {
                                "type": "object",
                                "properties": {
                                    "answers": {
                                        "type": "string",
                                        "description": "简答题答案"
                                    },
                                    "scoreDefault": {
                                        "type": "integer",
                                        "description": "默认分数"
                                    }
                                },
                                "description": "简答题主体",
                                "required": [
                                    "answers",
                                    "scoreDefault"
                                ]
                            }
                        ],
                        "description": "题目主体"
                    }
                },
                "required": [
                    "title",
                    "type",
                    "analysis",
                    "qt_body",
                    "difficulty"
                ]
            },
            "uniqueItems": false
        },
        "QBid": {
            "type": "integer",
            "description": "题库的id"
        },
        "username": {
            "type": "string",
            "description": "创建人账号"
        }
    },
    "required": [
        "questionArray",
        "QBid",
        "username"
    ]
}


// const questionvaildata =ajv.compile(question);
// const blankQuestiondata =ajv.compile(blankQuestion);



// function test(){
//
//     // let  a = {
//     //     "title": 123,
//     //     "type": [1,2],
//     //     "analysis": "enim nostrud incididunt officia consequat",
//     //     "qt_body": {
//     //         "selections": [
//     //             "labore dolore adipisicing fugiat"
//     //         ],
//     //         "answers": [
//     //             "aliquip Excepteur elit",
//     //             "culpa eiusmod dolore",
//     //             "ut dolor"
//     //         ],
//     //         "scoreDefault": [
//     //             "elit sunt cupidatat minim qui",
//     //             "proident deserunt incididunt",
//     //             "dolore anim Duis labore"
//     //         ]
//     //     },
//     //     "difficulty": 79
//     // }
//     // let a2 = {
//     //     "title": "直共务半",
//     //     "type": 2,
//     //     "analysis": "veniam enim consectetur voluptate sed",
//     //     "qt_body": {
//     //         "answers": [
//     //             "in eiusmod enim"
//     //         ],
//     //         "scoreDefault": [
//     //             4,
//     //             97,
//     //             77
//     //         ]
//     //     },
//     //     "difficulty": 44
//     // }
//     //
//     //
//     // let b = questionvaildata(a);
//     // let b2 = blankQuestiondata(a2)
//     //
//     // if(b) console.log(b)
//     // else console.log(questionvaildata.errors);
//     // if(b2) console.log(b2)
//     // else console.log(blankQuestiondata.errors);
//     // console.log(questionvaildata.errors);
// }
// test();


module.exports = {
    ChoiceQuestion,
    blankQuestion,
    judgingQuestion,
    shortAnswerQuestion
}